import { CHANGE_LANGUAGE, ADD_LANGUAGE, LanguageActionTypes } from "./actions";
export interface languageType {
  language: "en" | "zh";
  languageList: { label: string; code: string; key: string }[];
}

const defaultState: languageType = {
  language: "zh",
  languageList: [
    { label: "中文", code: "zh", key: "zh" },
    { label: "English", code: "en", key: "en" },
  ],
};
const languageReducer = (state = defaultState, action) => {
  switch (action.type) {
    case CHANGE_LANGUAGE:
      return { ...state, language: action.payload };
    case ADD_LANGUAGE:
      return {
        ...state,
        languageList: [...state.languageList, action.payload],
      };
    default:
      return state;
  }
};
export default languageReducer;
